package com.linkface.idcard;

import android.content.Context;

import com.linkface.card.CardRecognizer;
import com.linkface.card.CardScanner;

import java.util.HashMap;

/**
 * Copyright (c) 2017-2018 LINKFACE Corporation. All rights reserved.
 * <p>
 * IDard扫描类
 */
class IDCardScanner extends CardScanner {
    protected IDCardScanner(Context context, int currentFrameOrientation) {
        super(context, currentFrameOrientation, false);
        // 是否返回身份证类型
        if (mExtraRequestParams == null) {
            mExtraRequestParams = new HashMap<>();
        }
        mExtraRequestParams.put("return_type", "false");
    }

    @Override
    protected CardRecognizer initRecognizer(Context context){
        return new IDCardRecognizer(context);
    }

    /**
     * 设置IDCard扫描的识别模式参考IDCardRecognizer.Mode
     *
     * @param mode
     */
    public void setRecognizerMode(final int mode) {
        IDCardRecognizer idCardRecognizer = getIDCardRecognizer();
        if (idCardRecognizer != null) {
            idCardRecognizer.setMode(mode);
        }
    }

    public IDCardRecognizer getIDCardRecognizer() {
        IDCardRecognizer idCardRecognizer = null;
        CardRecognizer cardRecognizer = getCardRecognizer();
        if (cardRecognizer instanceof IDCardRecognizer) {
            idCardRecognizer = (IDCardRecognizer) cardRecognizer;
        }
        return idCardRecognizer;
    }
}
